if(typeof(thisURL) == "undefined") {
        var thisURL = (document.location.protocol + "//" + document.location.host + document.location.pathname).replace('www3', 'www');
}

if(typeof(thisFullURL) == "undefined") {
        var thisFullURL = encodeURIComponent((document.location.protocol + "//" + document.location.host + document.location.pathname + document.location.search).replace('www3', 'www'));
}

if(typeof(serviceURL) == "undefined") {
	var serviceURL = 'http://softwarecommunity.intel.com';
}

// render the StyleSheet
document.writeln("<style>");
document.writeln(".CB_SharedStyle {font-size:11px; font-family:Verdana;}");
document.writeln(".CB_LMargin {margin:5px;}");
document.writeln(".CB_TMargin {padding-top:5px;}");
document.writeln("#CB_Outter {width:300px;border:solid 1px #c0c0c0;}");
document.writeln("#CB_head {font-weight:bold;padding-bottom:5px;}");
document.writeln(".CB_MsgLenError {margin:0px;font-size:10px;color:red;}");
document.writeln(".CB_Buttons {text-align:right; padding-right:5px;}");
document.writeln(".CB_EmailNotDisplayed {font-size:10px;color:666666;}");
document.writeln(".CB_ProtectedByMsg {font-size:10px;color:666666;}");
document.writeln(".CB_CommentBox {width:275px;font-size:11px;font-family:Verdana}");
document.writeln(".CB_TextBox {width:275px;font-size:11px;font-family:Verdana}");
document.writeln("</style>");

var CBCommentPath = "";
var CB_Original;
var CB_Defined = true;
var CB_Added = false;
var CB_Required = { // validate in reverse for focus order as onscreen...
	cb_cmnt:true,
	cb_email:true,
	cb_name:true};
var CB_Localized = {
		leaveacomment:'Leave a comment',
		name:'Your Name',
		email:'Email <font class="CB_EmailNotDisplayed">(not displayed - keep spam away)</font>',
		comments:'Comments',
		submit:'Submit',
		submitting:'Submitting...',
		cancel:'Cancel',
		postcomment:'Post Comment',
		cb_cmnt:'Please Enter Comment',
		cb_name:'Please Enter Name',
		lengthTooLong:'(Comments are too long please shorten)',
		spamPost:'(Post is spam)', 
		protect:'<font class="CB_ProtectedByMsg">(Protected by <a href=http://akismet.com/>Akismet</a> AntiSpam tools)<br><br>Usage governed by <a target=_blank href=http://softwarecommunity.intel.com/articles/eng/1517.htm>Terms of Use</a></font>',
		lengthAllowed:1500
	};
var CB_T = function(t){return CB_Localized[t]||t;}
var CB_GetS = function(){getData(serviceURL+"/isn/home/CommonServices.ashx?F=GetS");}
var CB_PutS = function(P1){getData(serviceURL+"/isn/home/CommonServices.ashx?F=PutS&P1=" + P1 );}

var CB_maxL = CB_T('lengthAllowed');

function cbPostBackData()
{
	var cmTmp = "____________________________________";
	if (CB_Original != null)
		cmTmp = CB_Original;

	var p = {p:cmTmp,cpath:CBCommentPath,url:thisURL};
	for (var j in CB_Required) 
		p[j] = $('#' + j).val(); 
	var jsontxt = Object.toJSONString(p);
	jsontxt = encodeURIComponent(jsontxt);
	
	return jsontxt;
}

function cbCount() {
	if ( cbPostBackData().length <= CB_maxL )
		$('#CB_LenError').hide(); 
	$("#cbLenCounter").html((CB_maxL-cbPostBackData().length).toString());
	return true;
}

function dynAdd() {
	if ( !CB_Added) {
		CB_Added = true;
		$('#comments').append('<div id=CB_Outter class=CB_SharedStyle><div id="CB_Window" class="CB_LMargin"><div id="CB_head"></div><div id="CB_LenError" class="CB_MsgLenError"></div></div><br clear="all"/></div>');
		$('#CB_head').html(CB_T('leaveacomment')+':<span id=cbLenCounter style="font-weight: normal;"></span> <span style="font-weight: normal;">encoded chars left</span>');
		$('#CB_LenError').html(CB_T('lengthTooLong'));
		$('#CB_LenError').hide();
		$('#CB_Window').append('<div><div class=CB_TMargin>' + CB_T('name') + '</div><input onKeyUp="return cbCount()" type=text maxlength=128 id=cb_name class=CB_TextBox></div>');
		$('#CB_Window').append('<div><div class=CB_TMargin>' + CB_T('email') + '</div><input onKeyUp="return cbCount()" type=text maxlength=128 id=cb_email class=CB_TextBox></div>');
		$('#CB_Window').append('<div><div class=CB_TMargin>' + CB_T('comments') + '</div><textarea onKeyUp="return cbCount()" wrap=hard id=cb_cmnt rows=5 class=CB_CommentBox></textarea></div>');
		$('#CB_Window').append('<div class="CB_Buttons"><input type=button value=Submit id=cb_cmdSubmit class=CB_SharedStyle>&nbsp;<input type=button value=Cancel id=cb_cmdCancel class=CB_SharedStyle>&nbsp;</div><div>' + CB_T('protect') + '</div>');
		$('#cb_cmdSubmit').val(CB_T('submit'));
		$('#cb_cmdCancel').val(CB_T('cancel'));
		$('#CB_Outter').hide();
		$("#cb_cmdSubmit").click(CB_submit);
		$("#cb_cmdCancel").click(CB_cancel);
	} else {
		$('#CB_Outter').show(); CB_GetS();
	}

	$("#cbLenCounter").html(CB_maxL-cbPostBackData().length);
}

function CB_PostEvent(ok) {
	$('#cb_cmdSubmit').val(CB_T('submit'));
	$('#cb_cmdSubmit').attr("disabled", "");

	if(ok) {
		$('#cb_cmnt').val('');
		if(window.getComments && $("#commentText").is("div")) {
			getComments();
		}
		CB_cancel();

		// post comment submit action extend	
		if (CB_PostEvent.extend != null) CB_PostEvent.extend();	
	} else {
		$('#cb_name').prev().append('<font id=cb_nameerr' + ' color=red> ' + CB_T('spamPost') + '</font>');
	}
}

function CB_cancel() {
	for(var j in CB_Required) {
		$('#' + j + 'err').remove();
	}
	$('#CB_LenError').hide();
	$('#CB_Outter').hide();
	CB_Original = null;
}

function CB_submit() {
	if(CB_Original == null) {
		return;
	}

	$('#cb_cmdSubmit').val(CB_T('submitting'));
	$('#cb_cmdSubmit').attr("disabled", "disabled");

	var totalLen=0;
	var err;
	for (var j in CB_Required) {
		$('#' + j).val($.trim($('#' + j).val()));
		$('#' + j + 'err').remove();
		if ( CB_Required[j] && $('#' + j).val() == "") {
			err = j;
			$('#' + j).prev().append('<font id=' + j + 'err' + ' color=red>*</font>');
		}
	}
	
	if (err!=null) $('#' + err).focus();
	if (CB_maxL-cbPostBackData().length < 0) { 
		err=true; 	
		$('#cb_cmdSubmit').val(CB_T('submit'));
		$('#cb_cmdSubmit').attr("disabled", ""); 
		$('#CB_LenError').show(); 
	}
	if (err!=null) return;

	$("head/script#jsonrequest*").remove(); 
	
	CB_PutS(cbPostBackData());
}

// after the page load lets set get the comments and setup the comment data entry form
$(document).ready(function(){
	dynAdd();

	// Check if Override of how comments are stored is turned on
	if(CBCommentPath.length > 0) {
		thisURL = document.location.protocol + "//" + document.location.hostname + CBCommentPath;
	}
	if(window.getComments && $("#commentText").is("div")) {
		getComments();
	}
});

/*
    json.js
    2006-04-28

    This file adds these methods to JavaScript:

        object.toJSONString()

            This method produces a JSON text from an object. The
            object must not contain any cyclical references.

        array.toJSONString()

            This method produces a JSON text from an array. The
            array must not contain any cyclical references.

        string.parseJSON()

            This method parses a JSON text to produce an object or
            array. It will return false if there is an error.
*/
(function () {
    var m = {
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        s = {
            array: function (x) {
                var a = ['['], b, f, i, l = x.length, v;
                for (i = 0; i < l; i += 1) {
                    v = x[i];
                    f = s[typeof v];
                    if (f) {
                        v = f(v);
                        if (typeof v == 'string') {
                            if (b) {
                                a[a.length] = ',';
                            }
                            a[a.length] = v;
                            b = true;
                        }
                    }
                }
                a[a.length] = ']';
                return a.join('');
            },
            'boolean': function (x) {
                return String(x);
            },
            'null': function (x) {
                return "null";
            },
            number: function (x) {
                return isFinite(x) ? String(x) : 'null';
            },
            object: function (x) {
                if (x) {
                    if (x instanceof Array) {
                        return s.array(x);
                    }
                    var a = ['{'], b, f, i, v;
                    for (i in x) {
                        v = x[i];
                        f = s[typeof v];
                        if (f) {
                            v = f(v);
                            if (typeof v == 'string') {
                                if (b) {
                                    a[a.length] = ',';
                                }
                                a.push(s.string(i), ':', v);
                                b = true;
                            }
                        }
                    }
                    a[a.length] = '}';
                    return a.join('');
                }
                return 'null';
            },
            string: function (x) {
                if (/["\\\x00-\x1f]/.test(x)) {
                    x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
                        var c = m[b];
                        if (c) {
                            return c;
                        }
                        c = b.charCodeAt();
                        return '\\u00' +
                            Math.floor(c / 16).toString(16) +
                            (c % 16).toString(16);
                    });
                }
                return '"' + x + '"';
            }
        };

    Object.toJSONString = function (obj) {
        return s.object(obj);
    };

    //Array.prototype.toJSONString = function (obj) {
    //   return s.array(obj);
    //};
})();

//String.prototype.parseJSON = function () {
//    try {
//        return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
//                this.replace(/"(\\.|[^"\\])*"/g, ''))) &&
//            eval('(' + this + ')');
//    } catch (e) {
//        return false;
//    }
//};
function w(ref, height, width, scrollbar) {
 if (scrollbar == "true") { scrollbar = "yes"; } else { scrollbar = "no"; }
 window.open(ref+"?page="+encodeURIComponent(thisURL)+"&title="+document.title+"&lang=eng","w1","width="+width+",height="+height+",resizable=no,scrollbars="+ scrollbar+",toolbar=no,location=no,status=no,menubar=no");
}

function comment() {
 window.open(serviceURL+"/ISNCommunication/comment.aspx?page="+encodeURIComponent(thisURL)+"&title="+document.title+"&lang=eng","w2","width=420,height=370,resizable=no,scrollbars=yes,toolbar=no,location=no,status=no,menubar=no");
}

function vote(score) {
 window.open(serviceURL+"/ISNRatingWeb/ThankYou.aspx?rurl="+encodeURIComponent(thisURL)+"&rt="+score+"&ppu="+encodeURIComponent(thisURL)+"&lang=eng","ISNRate","width=325,height=250,resizable=0,scrollbars=0");
}

function tag(ref) {
 window.open(serviceURL+"/ISNTagWeb/ISNTagIT.aspx?turl="+encodeURIComponent(thisURL)+"&tdec="+document.title+"&taID=1&Lang=eng","ISNTag","width=700,height=400,resizable=0,scrollbars=1");
}

function p(url) {
 window.open(thisURL+"?prn=Y&"+location.search.substring(1),"prnWindow","toolbar=yes,status=no,height=600,width=780,scrollbars=yes");
}

function getData(url) {
 $.getScript(url);
}

function getComments() {
 $.getScript(serviceURL+"/isn/home/CommonServices.ashx?F=GetCommentsJSON&P1="+encodeURIComponent(thisURL)+"&P2=");
}

function getCommentsCallback(jRawData) {
 $("#commentText").html("");
 if(!jRawData) { return; }
 var jData = eval('(' + jRawData + ')');
 if(!jData) { return; }
 if(getCommentsCallback.extend != null) {
  getCommentsCallback.extend(jData);
 }
 var commentText = '';
 var display = '<div style="background: #efefef">%%email%% (%%date%%) wrote:</div><br />%%text%%<br /><br />';
 var len = jData.comments.length;
 if(len > 0) {
  for(i=0;i<len;i++) {
   if(jData.comments[i].email.length > 0) {
    var thisRow = display;
    thisRow = thisRow.replace("%%email%%",unEscape(jData.comments[i].email));
    thisRow = thisRow.replace("%%date%%",unEscape(jData.comments[i].date));
    thisRow = thisRow.replace("%%text%%",unEscape(jData.comments[i].text));
    commentText += thisRow;
   }
  }
  $("#commentText").html(commentText);
 }
}

function unEscape(psEncodeString) {
 var lsRegExp = /\+/g;
 return decodeURIComponent(String(psEncodeString).replace(lsRegExp, " "));
}

function getRating() {
 $.getScript(serviceURL+"/isn/home/CommonServices.ashx?F=GetRatingJSON&P1="+encodeURIComponent(thisURL)+"&P2=eng");
}

function getRatingCallback(jData) {
 if(!jData) { return; }
 if(getRatingCallback.extend != null) {
  getRatingCallback.extend(jData);
 }
 var voteText = '%%count%% users have voted, with a combined score of %%score%%.';
 voteText = voteText.replace('%%count%%',jData.RateCount);
 voteText = voteText.replace('%%score%%',jData.Rating);
 $("#voteText").html(voteText);
}

function getTags() {
 $.getScript(serviceURL+"/isn/home/CommonServices.ashx?F=GetTagsJSON&P1=0&P2=15&P3=eng");
}

function getTagsCallback(jData) {
 if(!jData) { return; }
 if(getTagsCallback.extend != null) {
  getTagsCallback.extend(jData);
 }
 var tagsText = '';
 var display = '<a href="%%url%%" class="font%%weight%%">%%tag%%</a>&#160; ';
 var len = jData.length;
 if(len > 0) {
  for(i=0;i<len;i++) {
   if(jData[i].TagName.length > 2) {
    var thisRow = display;
    thisRow = thisRow.replace('%%tag%%',jData[i].TagName);
    thisRow = thisRow.replace('%%weight%%',jData[i].TagWeight);
    thisRow = thisRow.replace('%%url%%',jData[i].TagUrl);
    tagsText += thisRow;
   }
  }
  $("#tagsText").html(tagsText + "<br /><br />");
 }
}

function getTagsForUrl() {
 $.getScript(serviceURL+"/isn/home/CommonServices.ashx?F=GetTagsForURLJSON&P1="+encodeURIComponent(thisURL)+"&P2=15&P3=eng");
}

function getTagsForUrlCallback(jData) {
 if(!jData) {
  $("#tagsForUrlText").html('');
 }
 if(getTagsForUrlCallback.extend != null) {
  getTagsForUrlCallback.extend(jData);
 }
 if(!jData) { return; }
 var tagsForUrlText = '';
 var display = '<a href="%%url%%" class="font%%weight%%">%%tag%%</a>&#160; ';
 var len = jData.length;
 if(len > 0) {
  for(i=0;i<len;i++) {
   if(jData[i].TagName.length > 2) {
    var thisRow = display;
    thisRow = thisRow.replace('%%tag%%',jData[i].TagName);
    thisRow = thisRow.replace('%%weight%%',jData[i].TagWeight);
    thisRow = thisRow.replace('%%url%%',jData[i].TagUrl);
    tagsForUrlText += thisRow;
   }
  }
  $("#tagsForUrlText").html("<div class='sectionHeading'>Tags for this Page</div><div class='sectionBody'>"+tagsForUrlText+"</div>");
 }
}
// Render the StyleSheet
document.writeln("<style>");
document.writeln(".jqmEF {display: none;position: fixed;top: 17%;left: 50%;margin-left: -200px; font-family:verdana,sans-serif;font-size: 11px;background-color: #E7E7E7;color: #000000; border:1px solid #6699CC; padding:0px;}");
document.writeln(".EFin {width: 385px;}");
document.writeln(".FTab {width: 100%;}");
document.writeln(".EF_MsgLenError {margin:0px;font-size:10px;color:red;}");
document.writeln("#eafmessage, #eafsubject, #eafemail, #eafrecipentemail {font-family:verdana,sans-serif;font-size: 11px;}");
document.writeln("#eafmessage {width:370px;}");
document.writeln(".FHead { width: 50%; color:#ffffff; font-family:verdana,sans-serif;font-size: 11px; background-color:#6699CC;}");
document.writeln(".FBody { padding-top:8px; padding-left:8px; text-align:left; width: 100%; font-family:verdana,sans-serif; font-size: 11px;}");
document.writeln("* html .jqmEF {width:238px; position: absolute;top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(17 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px');}");
document.writeln(".jqmOverlay { background-color: #262626; }");
document.writeln("a.jqmClose, .jqmClose { color: #ffffff;}");
document.writeln(".groovybutton {background-image:url(/common/images/back03.gif);border:1px solid #DDDDDD;font-family:Verdana,sans-serif;font-size:11px;height:20px;}");
document.writeln("</style>");

var EF_Required = { // validate in reverse for focus order as onscreen...
	eafmessage:true,
	eafsubject:true,
	eafurl:false,
	eafemail:true,
	eafrecipentemail:true
	};

var EF_Localized = {
		eafhdr:'Email This Page',
		eafsaveerror:'Sorry the system is busy, try again later.',
		eafsent:'Email Sent',
		eafheader:'Email this page to your friend. Complete the form below and click on the "send" button. All fields are required to help prevent spam.',
		eafemail:'Your email address:',
		eafrecipentemail:'Recipients email address:',
		eafsubject:'Subject:',
		eafmessage:'Message:',
		eafsubmit:'Submit',
		eafclose:'Close',
		eaflengthTooLong:'(Message too long please shorten)',
		eaftotallen:1900
	};
var EF_T = function(t){return EF_Localized[t]||t;}

// run after page is entirely done loading
$(document).ready(function() {

	$(document.body).prepend(
			  '<div class="jqmEF" id="efb2">'
			+ '	<div class="EFin" >'
			+ '	<table class=FTab cellpadding=5 cellspacing=0>'
			+ '	<tr><td class="FHead" align=left><b>' + EF_T('eafhdr') + '</b>&nbsp;&nbsp;</td><td align=right class="FHead"><a href="#" class="jqmClose" style="color: #ffffff;">' + EF_T('eafclose') + '</a></td></tr>'
			+ '	<tr><td colspan="2" class="FBody">'
			+ '		<div id="EF_LenError" class="EF_MsgLenError"></div>'
			+ '		<div>' + EF_T('eafheader') + '</div><br><br>'
			+ '		<div>' + EF_T('eafrecipentemail') + '</div><input type="text" size="40" maxlength="255" id="eafrecipentemail"><br><br>'
			+ '		<div>' + EF_T('eafemail') + '</div><input type="text" size="40" maxlength="255" id="eafemail"><br><br>'
			+ '		<div>' + EF_T('eafsubject') + '</div><input type="text" size="40" maxlength="255" id="eafsubject"><br><br>'
			+ '		<div>' + EF_T('eafmessage') + '</div><TEXTAREA id="eafmessage" rows="6"></TEXTAREA>'
			+ '		<br><input type="button" class="groovybutton" onclick="javascript:processEAF();" value="' + EF_T('eafsubmit') + '"><input type="hidden" id="eafurl">'
			+ '	</td><tr>'
			+ '	</table>'
			+ '	</div>'
			+ '</div>'
      );
	$('#EF_LenError').html(EF_T('eaflengthTooLong'));
	$('#EF_LenError').hide();

	$('#efb2').jqm({
		overlay:10,
		modal: true,
		onHide: function(hash){
			$('#EF_LenError').hide();
			hash.w.fadeOut('1000',function(){ hash.o.remove(); });
		}
	});
	
});


function eaf(eafTitle, eafURL)
{
	if ( arguments.length == 0)
	{
		$("#eafsubject").val(document.title);
		$("#eafurl").val(thisURL);
	}

	//$("#eafmessage").val("");
	$("#efb2").jqm().jqmShow();
}



//User clicked on the Submit Button
function processEAF()
{
	var err;
	for (var j in EF_Required) {
		$('#' + j).val($.trim($('#' + j).val()));
		$('#' + j + 'err').remove();
		if ( ( (j == "eafemail" || j == "eafrecipentemail") && !isValidEmail($("#" + j).val())) || (EF_Required[j] && $('#' + j).val() == "")) {
			err = j;
			$('#' + j).prev().append('<font id=' + j + 'err' + ' color=red>*</font>');
		}
	}

	var sendQS = "";
	sendQS += ("&P1=" + encodeURIComponent($('#eafmessage').val()));
	sendQS += ("&P2=" + encodeURIComponent($('#eafsubject').val()));
	sendQS += ("&P3=" + encodeURIComponent($('#eafurl').val()));
	sendQS += ("&P4=" + encodeURIComponent($('#eafemail').val()));
	sendQS += ("&P5=" + encodeURIComponent($('#eafrecipentemail').val()));

	if (err!=null) $('#' + err).focus();
	if (sendQS.length>EF_T('eaftotallen')) { err=true; $('#EF_LenError').show(); }
	if (err!=null) return;

	//alert(serviceURL + "/isn/home/CommonServices.ashx?F=ProcessEAF" + sendQS);
	getData(serviceURL + "/isn/home/CommonServices.ashx?F=ProcessEAF" + sendQS);
}

function processEAFCallback(eafDataSaved)
{
	if ( !eafDataSaved)
		alert(EF_T('eafsaveerror'));
	else
	{
		alert(EF_T('eafsent')); // worked and saved
		//$("#eafmessage").val("");
		$("#efb2").jqmHide();
	}
}

// very simple email check
function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}


// Render the StyleSheet
document.writeln("<style>");
document.writeln(".jqmFW {display: none;position: fixed;top: 17%;left: 50%;margin-left: -200px; font-family:verdana,sans-serif;font-size: 11px;background-color: #E7E7E7;color: #000000; border:1px solid #6699CC; padding:0px;}");
document.writeln(".FWin {width: 385px;}");
document.writeln(".FTab {width: 100%;}");
document.writeln(".FB_MsgLenError {margin:0px;font-size:10px;color:red;}");
document.writeln("#femail {font-family:verdana,sans-serif;font-size: 11px;}");
document.writeln("#fmessage { width:370px; font-family:verdana,sans-serif;font-size: 11px;}");
document.writeln(".FHeadL,.FHeadR { color:#ffffff; font-family:verdana,sans-serif;font-size: 11px; background-color:#6699CC;}");
document.writeln(".FHeadL {width:75%;} .FHeadR {width:25%;} .FBody { padding-top:8px; padding-left:8px; text-align:left; width: 100%; font-family:verdana,sans-serif; font-size: 11px;}");
document.writeln("* html .jqmFW {width:238px; position: absolute;top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(17 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px');}");
document.writeln(".jqmOverlay { background-color: #262626; }");
document.writeln("a.jqmClose, .jqmClose { color: #ffffff;}");
document.writeln(".groovybutton {background-image:url(/common/images/back03.gif);border:1px solid #DDDDDD;font-family:Verdana,sans-serif;font-size:11px;height:20px;}");
document.writeln("</style>");

var FB_Required = { // validate in reverse for focus order as onscreen...
	fmessage:true,
	ftitle:false,
	furl:false,
	femail:true};

var FB_Localized = {
		feedbackhdr:'Feedback For This Page',
		feedbacksaveerror:'Sorry the system is busy, try again later.',
		feedbacksent:'Feedback Sent',
		feedbackemail:'Your email address:',
		feedbackmessage:'Message:',
		feedbacksubmit:'Submit',
		feedbackclose:'Close',
		feedbacklengthTooLong:'(Feedback too long please shorten)',
		feedbacktotallen:1900
	};
var FB_T = function(t){return FB_Localized[t]||t;}

var FB_maxL = FB_T('feedbacktotallen');

function fbPostBackData()
{
	var sendQS = "";
	sendQS += ("&P1=" + encodeURIComponent($('#fmessage').val()));
	sendQS += ("&P2=" + encodeURIComponent($('#ftitle').val()));
	sendQS += ("&P3=" + encodeURIComponent($('#furl').val()));
	sendQS += ("&P4=" + encodeURIComponent($('#femail').val()));
	return sendQS;
}

function fbCount() {
	if ( fbPostBackData().length <= FB_maxL )
		$('#FB_LenError').hide(); 
	$("#fbLenCounter").html((FB_maxL-fbPostBackData().length).toString());
	return true;
}

// run after page is entirely done loading
$(document).ready(function() {

	$(document.body).prepend(
			  '<div class="jqmFW" id="fb2">'
			+ '	<div class="FWin" >'
			+ '	<table class=FTab cellpadding=5 cellspacing=0>'
			+ '	<tr><td class="FHeadL" align=left><b>' + FB_T('feedbackhdr') + '</b>:<span id=fbLenCounter></span></td><td align=right class="FHeadR"><a href="#" class="jqmClose" style="color: #ffffff;">' + FB_T('feedbackclose') + '</a></td></tr>'
			+ '	<tr><td colspan="2" class="FBody">'
			+ '		<div id="FB_LenError" class="FB_MsgLenError"></div>'
			+ '		<div>' + FB_T('feedbackemail') + '</div><input onKeyUp="return fbCount()" type="text" size="40" maxlength="255" id="femail"><input type="hidden" id="ftitle"><input type="hidden" id="furl"><br><br>'
			+ '		<div>' + FB_T('feedbackmessage') + '</div><TEXTAREA onKeyUp="return fbCount()" id="fmessage" rows="6"></TEXTAREA>'
			+ '		<br><input type="button" class="groovybutton" onclick="javascript:processFeedback();" value="' + FB_T('feedbacksubmit') + '">'
			+ '	</td><tr>'
			+ '	</table>'
			+ '	</div>'
			+ '</div>'
      );
	$('#FB_LenError').html(FB_T('feedbacklengthTooLong'));
	$('#FB_LenError').hide();

	$('#fb2').jqm({
		overlay:10,
		modal: true,
		onHide: function(hash){
			$('#FB_LenError').hide();
			hash.w.fadeOut('1000',function(){ hash.o.remove(); });
		}
	});
	
});


function sfb(feedbackTitle, feedbackURL)
{
	if ( arguments.length == 0)
	{
		$("#ftitle").val(document.title);
		$("#furl").val(thisURL);
	}

	$("#fbLenCounter").html(FB_maxL-fbPostBackData().length);

	//$("#fmessage").val("");
	$("#fb2").jqm().jqmShow();
}



//User clicked on the Submit Feedback Button
function processFeedback()
{
	$('#FB_LenError').hide();

	// P1=encodeURIComponent()
	// P2=
	// P3=

	var err;
	for (var j in FB_Required) {
		$('#' + j).val($.trim($('#' + j).val()));
		$('#' + j + 'err').remove();
		if ( (j == "femail" && !isValidEmail($("#femail").val())) || (FB_Required[j] && $('#' + j).val() == "")) {
			err = j;
			$('#' + j).prev().append('<font id=' + j + 'err' + ' color=red>*</font>');
		}
	}

	if (err!=null) $('#' + err).focus();
	
	if (FB_maxL-fbPostBackData().length < 0) { err=true; $('#FB_LenError').show(); }
	if (err!=null) return;

	getData(serviceURL + "/isn/home/CommonServices.ashx?F=ProcessFeedback" + fbPostBackData());
}

function processFeedbackCallback(fbDataSaved)
{
	if ( !fbDataSaved)
		alert(FB_T('feedbacksaveerror'));
	else
	{
		alert(FB_T('feedbacksent')); // worked and saved
		$("#fmessage").val("");
		$("#fb2").jqmHide();
	}
}

// very simple email check
function isValidEmail(str) {
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

// Render the StyleSheet
document.writeln("<style>");
document.writeln(".jqmisnL {display: none;position: fixed;top: 17%;left: 50%;margin-left: -200px; font-family:verdana,sans-serif;font-size: 11px;background-color: #E7E7E7;color: #000000; border:1px solid #6699CC; padding:0px;}");
document.writeln(".isnLin {width: 285px;}");
document.writeln(".ISNTab {width: 100%;}");
document.writeln("#txtPassword, #txtUserName {font-family:verdana,sans-serif;font-size: 11px;}");
document.writeln(".ISNHead {padding:4px; width:50%; color:#ffffff; font-family:verdana,sans-serif;font-size: 11px; background-color:#6699CC;}");
document.writeln(".ISNBody {padding-bottom:8px;padding-top:8px; padding-left:8px; text-align:left; width: 100%; font-family:verdana,sans-serif; font-size: 11px;}");
document.writeln("* html .jqmisnL {width:238px; position: absolute;top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(17 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px');}");
document.writeln(".jqmOverlay { background-color: #262626; }");
document.writeln("a.jqmClose, .jqmClose { color: #ffffff;}");
document.writeln(".groovybutton {background-image:url(/common/images/back03.gif);border:1px solid #DDDDDD;font-family:Verdana,sans-serif;font-size:11px;height:20px;}");
document.writeln("</style>");

// Failsafe catch if loginURL is not defined
if ( typeof(loginURL) == "undefined")
	var loginURL = 'https://fm1cedar.cps.intel.com/isn/Login/Template.aspx'; 
	//var loginURL = 'http://kpirkl-desk.amr.corp.intel.com/isn/Login/Template.aspx'; // internal testing only
	//var loginURL = 'https://fmd0cedar01.cps.intel.com/isn/Login/Template.aspx';  // internal testing only


var isnL_Required = { // validate in reverse for focus order as onscreen...
	txtPassword:true,
	txtUserName:true
	};

var isnL_Localized = {
		isnLhdr:'Quick Login',
		txtUserName:'Login Id:',
		txtPassword:'Password:',
		isnLsubmit:'Submit',
		isnLclose:'Close'
	};

var isnL_T = function(t){return isnL_Localized[t]||t;}

// run after page is entirely done loading
$(document).ready(function() {
	$(document.body).prepend(
			  '<div class="jqmisnL" id="isnLb2">'
			+ '	<div class="isnLin" >'
			+ '<form id="frmLogin" name="frmLogin" method="post" action="' + loginURL + '?TARGET=' +  encodeURIComponent(thisURL) + '">'
			+ '	<table class=ISNTab cellpadding=5 cellspacing=0>'
			+ '	<tr><td class="ISNHead" align=left><b>' + isnL_T('isnLhdr') + '</b>&nbsp;&nbsp;</td><td  style="text-align:right;" align="right" class="ISNHead"><a href="#" class="jqmClose" style="color: #ffffff;">' + isnL_T('isnLclose') + '</a></td></tr>'
			+ '	<tr><td colspan="2" class="ISNBody">'
			+ '		<div>' + isnL_T('txtUserName') + '</div><input type="text" size="35" maxlength="255" id="txtUserName" name="txtUserName"><br><br>'
			+ '		<div>' + isnL_T('txtPassword') + '</div><input type="password" size="35" maxlength="255" id="txtPassword" name="txtPassword"><br><br>'
			+ '		<input type="submit" class="groovybutton" onclick="return validisnLData();" value="' + isnL_T('isnLsubmit') + '">'
			+ '	</td><tr>'
			+ '	</table>'
			+ '<input type="hidden" name="qlogin" value="true"></form>'
			+ '	</div>'
			+ '</div>'
      );

	$('#isnLb2').jqm({
		overlay:10,
		modal: true,
		onHide: function(hash){
			$('#isnL_LenError').hide();
			hash.w.fadeOut('1000',function(){ hash.o.remove(); });
		}
	});
	
});

function isnL()
{
	$("#txtUserName").val("");
	$("#txtPassword").val("");
	$("#isnLb2").jqm().jqmShow();
	$("#txtUserName").focus();
}

function validisnLData()
{
	var err;
	for (var j in isnL_Required) {
		$('#' + j).val($.trim($('#' + j).val()));
		$('#' + j + 'err').remove();
		if ( isnL_Required[j] && $('#' + j).val() == "") {
			err = j;
			$('#' + j).prev().append('<font id=' + j + 'err' + ' color=red>*</font>');
		}
	}
	if (err!=null) $('#' + err).focus();
	return (err==null);
}
$(document).ready(function() {
	$("ul.nav").superfish({
		hoverClass : "sfHover",
		delay : 5,
		animation : { opacity: "show" },
		speed : 1
	});
	$("#nav li").hover(
		function() {
			$("ul", this).bgIframe({opacity:true});
		},
		function() { }
	);
	$("#q").focus(function() {
		$(this).val('');  
	});
	if($("#right").is("div") && !($("#loginDiv").is("div"))) {
		$("#right").prepend("<div id='loginDiv'></div>").find("#loginDiv").load("/common/php/login.php?target="+encodeURIComponent(thisURL)+"&rand="+Math.random());
	}
	$("#hLang").change(function() {
		var url = $(this).val();
		if(url != '#') {
			document.location = url;
		}
	});
});

function digg() {
	document.location = 'http://www.digg.com/submit?phase=2&url='+encodeURIComponent(thisURL);
}

function delicious() {
	document.location = 'http://del.icio.us/post?url='+encodeURIComponent(thisURL);
}

function flash(url, w, h) {
	var id = 'id' + Math.random();
	document.write('<div id="'+id+'" style="height: '+h+'px; width: '+w+'px"></div>');
	var FO = {wmode:"transparent",xi:"true",movie:url,id:"mediaplayer",name:"mediaplayer",width:w,height:h,majorversion:"8",build:"0",bgcolor:"#fff",allowfullscreen:"true",flashvars:"" };
	UFO.create(FO, id);
}

var PA_Localized = {
		pollvote:'Vote',
		pollresult:'Results',
		poll_done_error:'You have already voted for this poll!',
		pollerror:'Please select a answer to poll!'
	};
var PA_T = function(t){return PA_Localized[t]||t;}

// run after page is entirely done loading
$(document).ready(function() {
   DisplayPoll();   
});
//Initial poll data
function DisplayPoll(){
	if ( $("#pollHere").is("div"))
	{
		var pollhtml = "";
		pollhtml += "<div class='box'>";
		pollhtml += "<div class='boxHeader'>";
		pollhtml += "<span id='pq'></span>";
		pollhtml += "</div>";
		pollhtml += "<div class='boxBody'>";
		pollhtml += "<div id='divpans'></div>";
		pollhtml += "</div></div>";
		$("#pollHere").html(pollhtml);
		polldata($("#pollHere").attr("pid"));
			
	}
}
function processpoll()
{
   var pid = $("#pollHere").attr("pid");
   var ansid = $("input[@name=poll_answers]:checked").val();
   var cookie_val = "";
   cookie_val = get_cookie("isn_poll");
   var res = check_poll_done(cookie_val,pid);
   if(res)
     alert(PA_T('poll_done_error'));
   else
	   dopoll(pid,ansid,cookie_val)
    return false;

}
function dopoll(pid,ansid,cookie_val)
{
   if(ansid != null){
    cookie_val = cookie_val + pid + "|"; 
    setcookie("isn_poll",cookie_val,"","intel.com","");
    getData(serviceURL 
		+ "/isn/home/CommonServices.ashx?F=ProcessPoll" 
		+ "&P1=" + pid + "&P2=" + ansid);
	 }
	else
	  alert(PA_T('pollerror'));
}

function getpollresults(pid)
{
   document.location.href = serviceURL+"/isn/polls/default.aspx?pid="+pid;
   return false;
}
function polldata(pid)
{
	getData(serviceURL 
		+ "/isn/home/CommonServices.ashx?F=GetPollData" 
		+ "&P1=" + pid + "&P2=none");
	 
}
function ShowPollData(data)
{
	var ans = "";
	$('#pq').html(data[0]['pollQuestion']);
	if(data.length > 0)
	{
		ans += '<table class="sectionbody">';
		for(var i=0;i<=data.length-1;i++)
		{
			ans += '<tr><td>';
			ans += data[i]['pollAnswer'];
			ans += '</td><td><span id = "poll_span_'+ data[i]['pollAnswerID'] + '" ansid='+ data[i]['pollAnswerID']+ '><input name="poll_answers" type=radio value="'+data[i]['pollAnswerID']+ '"/></span></td></tr>';
		}
		ans +='</table>';
		ans += "<div style='PADDING-LEFT:30px'><b><a href='#' onclick='return processpoll();'>"+PA_T('pollvote')+"</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick='return getpollresults("+data[0]['pollID']+");'>"+PA_T('pollresult')+"</a></b></div>";
	}
	$('#divpans').html(ans);
}
function setcookie(name,value,path,domain,secure)
{
  var cookie_string = name+"="+escape(value);
  var expires = new Date ( 2020, 01, 01 );
  cookie_string += "; expires=" + expires.toGMTString();
  if ( path )
        cookie_string += "; path=" + escape ( path );
  if ( domain )
        cookie_string += "; domain=" + escape ( domain );
  if ( secure )
        cookie_string += "; secure";
   document.cookie = cookie_string;
}
function delete_cookie(cookie_name)
{
  var cookie_date = new Date();  // current date &amp; time
  cookie_date.setTime(cookie_date.getTime() - 1);
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}
function get_cookie(cookie_name)
{
  var results = document.cookie.match(cookie_name + '=(.*?)(;|$)');
   if ( results )
    return (unescape( results[1]));
  else
    return "";
}
function check_poll_done(cookie_val,pollID)
{
   var cookie_array;
   if(cookie_val != "")
   {
     cookie_array = cookie_val.split("|");
     for(var i=0;i<=cookie_array.length-1;i++)
     {
        if(cookie_array[i] != ""){
          if(parseInt(cookie_array[i]) == pollID)
             return true;
         }
     }
   }
   return false;
}
document.writeln("<style>");
document.writeln(".jqmWindow {display: none;position: fixed;top: 17%;left: 50%;margin-left: -200px; font-family:verdana,sans-serif;font-size: 11px;background-color: #E7E7E7;color: #000000; border:1px solid #6699CC; padding:0px;}");
document.writeln(".voteWin {width: 100%;}");
document.writeln(".voteHead {color:#ffffff; background-color:#6699CC; display:inline; padding-left: 3px;padding-right: 3px;padding-top: 4px;padding-bottom: 4px;}");
document.writeln(".captchaDiv { text-align:center; width: 100%; padding-top:4px; padding-bottom:6px;}");
document.writeln("#captchaImg { padding-top:5px; padding-bottom:5px;}");
document.writeln("* html .jqmWindow {width:238px; position: absolute;top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(17 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px');}");
document.writeln(".jqmOverlay { background-color: #262626; }");
document.writeln("a.jqmClose, .jqmClose { color: #ffffff;}");
document.writeln(".groovybutton {background-image:url(/common/images/back03.gif);border:1px solid #DDDDDD;font-family:Verdana,sans-serif;font-size:11px;height:20px;}");
document.writeln("</style>");


var RA_Localized = {
		entercode:'Enter code as seen in image',
		closedialog:'Close',
		sendvote:'Send Vote'
	};
var RA_T = function(t){return RA_Localized[t]||t;}


var sessionId = "";  //Used for testing that session state is maintained across domains

// run after page is entirely done loading
$(document).ready(function() {

	$(document.body).prepend(
			'<div class="jqmWindow" id="ex2">'
			+ '	<div class="voteWin" >'
			+ '	<div class="voteHead"><b>' + RA_T('entercode') + '</b>&nbsp;&nbsp;</div><div class="voteHead"><a href="#" class="jqmClose" style="color: #ffffff;">' + RA_T('closedialog') + '</a></div>'
			+ '	<div align="center" class="captchaDiv">'
			+ '		<img id="captchaImg"><br>'
			+ '		<input type="hidden" id="voteDirection" value="1">'
			+ '		<input type="hidden" id="voteDocId" value="">'
			+ '		<input type="text" id="captchaImgValEntered" maxlength="10" style="width:100px">&nbsp;<input type="button" class="groovybutton" onclick="javascript:processVote();" value="' + RA_T('sendvote') + '">'
			+ '		<br>'
			+ '	</div>'
			+ '	</div>'
			+ '</div>'
      );
	
	if ( $("#voteRateHere").is("div"))
	{
		$("#voteRateHere").html('<a href="javascript:voteForThis(1)"><img alt="Thumbs Up" border="0" height="16" src="http://cache-www.intel.com/plt/cd/software/shared/images/icons/thumbsup.gif" title="Thumbs Up" width="16"></a>&nbsp;<span id=upvotes></span>&nbsp;|&nbsp;<a href="javascript:voteForThis(0)"><img alt="Thumbs Down" border="0" height="16" src="http://cache-www.intel.com/plt/cd/software/shared/images/icons/thumbsdown.gif" title="Thumbs Down" width="16"></a>&nbsp;<span id=downvotes></span>');

		if(getRatingCallback.extend == null) {
			getRatingCallback.extend = function(jData) { 
				var downscore = jData.RateCount-jData.Rating; 
				$("#upvotes").html(jData.Rating);    
				$("#downvotes").html(downscore.toString()); 
			}; 
		}

		getRating();
	}

	$('#ex2').jqm({
		overlay:10,
		modal: true,
		onHide: function(hash){
			hash.w.fadeOut('1000',function(){ hash.o.remove(); });
		}
	});
	
});


function voteForThis(v, overrideUrl)
{
	getNewCaptchaImage();
	if ( overrideUrl != null)
		thisURL = overrideUrl;

	$("#captchaImgValEntered").val("");
	//$("#voteDocId").val(id);
	$("#voteDirection").val(v);
	$("#ex2").jqm().jqmShow();
}


//Callback after Captcha is called to get a new image to check
function setCaptchaCallback(sid)
{
	sessionId = sid; // Users ASP.Net Session Id
	$("#captchaImg").attr("src",serviceURL + "/isn/home/Captcha.aspx" + "?noCache=" + (new Date()).getTime());
}

//User clicked on the Submit Vote Button
function processVote()
{
	var captchaImgValEntered = $("#captchaImgValEntered").val(); // User entered value
	captchaImgValEntered = $.trim(captchaImgValEntered);
	// P1=UserEnteredCaptchaVal
	// P2=rate 0 or 1 for yes or no
	// P3=url being rated
	// P4=IsoLanguage Code [eng or autodetected based on browser settings]
	// P5=Captcha Session Id to beat script attackers
	getData(serviceURL 
		+ "/isn/home/CommonServices.ashx?F=ProcessVote" 
		+ "&P1=" + escape(captchaImgValEntered) 
		+ "&P2=" + $("#voteDirection").val()
		+ "&P3=" + encodeURIComponent(thisURL)
		+ "&P4=eng"
		+ "&P5=" + sessionId);
	
	waCustomLink(this,"Vote","o", "wa_custom13=" + $("#voteDirection").val() + "&wa_custom07=" + encodeURIComponent(document.title) + "&wa_events=se_cust01"); 
}

function captchaCallback(returnResults)
{
	if ( returnResults == "0")
	{
		//oops it appears to be a session timeout or incorrect value
		$("#captchaImgValEntered").val("");
		getNewCaptchaImage(); //get a new image in case the user just cant see the one they are getting
	}
	else
	{
		alert("Vote Saved"); // worked and saved
		try { 
			$("#ex2").jqmHide();
			$("#captchaImgValEntered").val("");
			getNewCaptchaImage(); //done so get a new image for voting
			getRating(); 
		} catch(err){}
	}
}

function getNewCaptchaImage() {
	getData(serviceURL+"/isn/home/Captcha.aspx?id=0" + "&noCache=" + (new Date()).getTime());
}

/*
Options:
ARC.noFirstRow();  
*/

function AlternateRowColors() {
  this.allTables = [];
  this.arcTables = [];
  this.firstRow = true;
  this.old_onload = window.onload;
  window.onload = this.init;
  window.arcReference = this;
};

AlternateRowColors.prototype.noFirstRow = ARC_noFirstRow;
AlternateRowColors.prototype.init = ARC_init;

function ARC_init() {
  if(!document.getElementsByTagName) { return; };
  var ARC = window.arcReference;
  ARC.thisType = "";
  ARC.allTables = document.getElementsByTagName("table");
  for(var i=0; i<ARC.allTables.length; i++) {
    if(ARC.allTables[i].className.toLowerCase().substring(0,11) == "tableformat") {
      ARC.arcTables = ARC.arcTables.concat(ARC.allTables[i]);
      ARC.thisType = ARC.allTables[i].className.toLowerCase();
    }
  }
  if(ARC.arcTables.length < 1) { return; };
  for(var jab=0; jab<ARC.arcTables.length; jab++) {
    var table = ARC.arcTables[jab];
    if(ARC.firstRow) {
      table.rows[0].className = ARC.thisType + "FirstRow";
      for(colCount=0; colCount<table.rows[0].cells.length-1; colCount++) {
         table.rows[0].cells[colCount].className = ARC.thisType + "FirstRowCol";
      }
    };
    var rowCount;
    (ARC.firstRow) ? (rowCount = 1) : (rowCount = 0);
    for(rowCount; rowCount<table.rows.length; rowCount++) {
      var tableRow = table.rows[rowCount];
      (rowCount%2 == 0) ? (tableRow.className = ARC.thisType + "RowEven") : (tableRow.className = ARC.thisType + "RowOdd");
      for(colCount=0; colCount<tableRow.cells.length; colCount++) {
         var tableCol = tableRow.cells[colCount];
         tableCol.className = ARC.thisType + "Col";
      }
    }
  }
};

function ARC_noFirstRow() { this.firstRow = false; };

var ARC = new AlternateRowColors();


