/* Script Name: Javascript Cookie Script Author: Public Domain, with some modifications Script Source URI: http://techpatterns.com/downloads/javascript_cookies.php Version 1.1.2 Last Update: 5 November 2009 Changes: 1.1.2 explicitly declares i in Get_Cookie with var 1.1.1 fixes a problem with Get_Cookie that did not correctly handle case where cookie is initialized but it has no "=" and thus no value, the Get_Cookie function generates a NULL exception. This was pointed out by olivier, thanks 1.1.0 fixes a problem with Get_Cookie that did not correctly handle cases where multiple cookies might test as the same, like: site1, site This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ // this fixes an issue with the old method, ambiguous values // with this test document.cookie.indexOf( name + "=" ); // To use, simple do: Get_Cookie('cookie_name'); // replace cookie_name with the real cookie name, '' are required function Get_Cookie( check_name ) { // first we'll split this cookie up into name/value pairs // note: document.cookie only returns name=value, not the other components var a_all_cookies = document.cookie.split( ';' ); var a_temp_cookie = ''; var cookie_name = ''; var cookie_value = ''; var b_cookie_found = false; // set boolean t/f default f var i = ''; for ( i = 0; i < a_all_cookies.length; i++ ) { // now we'll split apart each name=value pair a_temp_cookie = a_all_cookies[i].split( '=' ); // and trim left/right whitespace while we're at it cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, ''); // if the extracted name matches passed check_name if ( cookie_name == check_name ) { b_cookie_found = true; // we need to handle case where cookie has no value but exists (no = sign, that is): if ( a_temp_cookie.length > 1 ) { cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') ); } // note that in cases where cookie is initialized but no value, null is returned return cookie_value; break; } a_temp_cookie = null; cookie_name = ''; } if ( !b_cookie_found ) { return null; } } /* only the first 2 parameters are required, the cookie name, the cookie value. Cookie time is in milliseconds, so the below expires will make the number you pass in the Set_Cookie function call the number of days the cookie lasts, if you want it to be hours or minutes, just get rid of 24 and 60. Generally you don't need to worry about domain, path or secure for most applications so unless you need that, leave those parameters blank in the function call. */ function Set_Cookie( name, value, expires, path, domain, secure ) { // set time, it's in milliseconds var today = new Date(); today.setTime( today.getTime() ); // if the expires variable is set, make the correct expires time, the // current script below will set it for x number of days, to make it // for hours, delete * 24, for minutes, delete * 60 * 24 if ( expires ) { //expires = expires * 1000 * 60 * 60 * 24; expires = expires * 1000 * 60 * 60 * 1; } //alert( 'today ' + today.toGMTString() );// this is for testing purpose only var expires_date = new Date( today.getTime() + (expires) ); //alert('expires ' + expires_date.toGMTString());// this is for testing purposes only document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString() ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" ); } // this deletes the cookie when called function Delete_Cookie( name, path, domain ) { if ( Get_Cookie( name ) ) document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; } function gup( name ) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1]; } var munc_adv_cnt_reset = gup ('munc_debug'); var server_show_debug = 0; if(munc_adv_cnt_reset == 1) Delete_Cookie( 'munc_adv_cnt', '/', '' ); if ( Get_Cookie( 'munc_adv_cnt' ) == 1){ //ad already delivered, we have to wait } else { var server_client_id=1008; var server_ad_filter3=1008; // var server_ad_keyword = gup('symbol'); var server_ad_keyword = gup('selected'); if(server_ad_keyword.length < 1 ){ // var server_ad_keyword = gup ('selected'); var server_ad_keyword = gup ('symbol'); } if(server_ad_keyword.length < 1 ){ var server_ad_keyword = gup ('stockticker'); } var server_code_version = 4; var server_ad_channel = 1; var server_ad_only_results = 1; var server_ad_count = 1; // if(munc_adv_cnt_reset == 1) var server_ad_channel = 2; // if(munc_adv_cnt_reset == 1) var server_ad_channel = 2; // var server_show_debug = 1; var server_client_id; var server_ad_width; var server_ad_height; var server_ad_style; var server_code_version; var server_ad_border_width; var server_ad_color_border; var server_ad_color_background; var server_ad_color_headline; var server_ad_color_body; var server_ad_color_url; var server_ad_keyword; var server_ad_random; var server_ad_channel; var server_publisher_channels; var server_ad_count; var server_ad_offset; var server_code_justify; var server_ad_only_results; var server_ad_top_text; var server_ad_location = escape(document.URL); var code_search; var server_ad_region; var server_sem_url; var server_ad_filter1; var server_ad_filter2; var server_ad_filter3; var server_ignore_frameset; if(server_ad_border_width){ var ad_show_border = server_ad_border_width; } if (server_ad_location){ var ad_document_location = server_ad_location; var ad_location = server_ad_location; } if(server_ad_top_text){ var inclick_ad_top_text = server_ad_top_text; } var server_contextual; if(server_contextual == 0){ var incontext = 0; } else { var incontext = 1; } if(server_ad_only_results >= 0 ){ var ad_limited = server_ad_only_results; } else { var ad_limited = 0; } if(server_code_justify) { var code_justify = server_code_justify; } if(server_ad_count) { var ad_count = server_ad_count; } if(server_ad_offset >= 0) { var docoffset = server_ad_offset; } else { var docoffset = 0; } if(server_ad_random >= 0) { var inclick_ad_random = server_ad_random; } if(server_ad_channel) { var ad_zone = server_ad_channel; } var publisher_channels = ""; if (server_publisher_channels) { publisher_channels = server_publisher_channels; } if(server_ad_keyword) { if (encodeURIComponent) { var ad_keyword = encodeURIComponent(server_ad_keyword); } else { var ad_keyword = escape(server_ad_keyword); } var incontext = 0; } else { var ad_keyword = ""; var incontext = 1; } if(server_ad_color_border) { var ad_show_border_color = server_ad_color_border; } if(server_ad_color_background) { var ad_show_bg_color = server_ad_color_background; } if(server_ad_color_headline) { var inclick_ad_color_headline = server_ad_color_headline; } if(server_ad_color_body) { var inclick_ad_color_body = server_ad_color_body; } if(server_ad_color_url) { var inclick_ad_color_url = server_ad_color_url; } if(server_code_version) { var inclick_code_version = server_code_version; } if(server_ad_width) { var ad_tile_width = server_ad_width; } if(server_ad_height) { var inclick_ad_height = server_ad_height; } if(server_client_id) { var ad_publisher_id = server_client_id; } if(server_ad_style) { var inclick_ad_style = server_ad_style; } else { var inclick_ad_style = ""; } if(server_ad_region){ var region = server_ad_region; } else { var region = ""; } if (server_ad_filter1) { if (encodeURIComponent) { var filter1 = encodeURIComponent(server_ad_filter1); } else { var filter1 = escape(server_ad_filter1); } } else { var filter1=""; } if (server_ad_filter2) { if (encodeURIComponent) { var filter2 = encodeURIComponent(server_ad_filter2); } else { var filter2 = escape(server_ad_filter2); } } else { var filter2=""; } if (server_ad_filter3) { if (encodeURIComponent) { var filter3 = encodeURIComponent(server_ad_filter3); } else { var filter3 = escape(server_ad_filter3); } } else { var filter3=""; } var next_request_easy ; var next_request_easy_count; if(next_request_easy == 1){ docoffset = docoffset + next_request_easy_count ; next_request_easy_count= docoffset + ad_count; } else { next_request_easy_count = ad_count; } var next_request_easy = 1; var currentURL = document.URL; if (!server_ignore_frameset) { try { currentURL = top.location.href; if (typeof(currentURL) == "undefined") { throw "undefined"; } } catch(exception) { currentURL = document.referrer; if (currentURL == "" || typeof(currentURL) == "undefined") { currentURL = document.URL; } } } ad_document_location = currentURL; var i; var ad_title = new Array(); var ad_clickthru = new Array(); var ad_description = new Array(); var ad_domain = new Array(); var ad_cpc = new Array(); var ad_richmedia = new Array(); var inclick_ad_random; var ad_extended_media; var ad_extended_media_ht; var ad_extended_media_wt; var ad_style; var ad_media_url = new Array(); var ad_media_type = new Array(); if(next_query_offset == undefined) { var next_query_offset = 0; } var ad_offset = ad_offset + next_query_offset; var ran_number= Math.random()*100000000; document.write(""); document.write(""); document.oldCharset = document.charset; document.charset="UTF-8"; document.write(''); //document.write(''); } if(munc_adv_cnt_reset == 1) Delete_Cookie( 'munc_adv_cnt', '/', '' );