function getCookie(c_name){if (document.cookie.length>0)  {  c_start=document.cookie.indexOf(c_name + "=");  if (c_start!=-1)    {    c_start=c_start + c_name.length+1;    c_end=document.cookie.indexOf(";",c_start);    if (c_end==-1) c_end=document.cookie.length;    return unescape(document.cookie.substring(c_start,c_end));    }  }return "";}function setCookie(c_name,value,expiredays){var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());}/** * Return the sample id of the specified url or null if the specified url doesn't  * refer a sample */ function getSampleId(aURL){	 sample_dir_index=aURL.indexOf('data/samples/');	 if (sample_dir_index!=-1)	 {  	 sample_href=aURL.substring(sample_dir_index+13);  	 ext_index=sample_href.indexOf(".oml");  	 if ((ext_index!=-1)&(sample_href.indexOf("proxy.php")==-1))  	 {  	   sample_id=sample_href.substring(0,ext_index);  	   return sample_id;  	 }   }   return null;}function rewriteURLs(anIframe,aProxyPrefix) {	var doc = (anIframe.contentWindow || anIframe.contentDocument);  if (doc.document) doc = doc.document;	for (i=0;i<doc.images.length;i++)	{		doc.images[i].src=aProxyPrefix+escape(doc.images[i].src);	}	base_url=document.location.href.replace(/%3A/g,":");	base_uri=base_url.substring(0,base_url.lastIndexOf(':'));	for (i=0;i<doc.links.length;i++)	{	 sample_id=getSampleId(doc.links[i].href);	 if (sample_id!=null)	 {  	   doc.links[i].href="javascript:window.parent.location.href='"+base_uri+':'+sample_id+"'";   }	}	base_sample_ns=base_uri.substring(base_uri.indexOf("id=")+3);	for (i=0;i<doc.forms.length;i++)	{	 sample_id=getSampleId(doc.forms[i].action);	 if (sample_id!=null)	 {	    doc.forms[i].target="_parent";      var h=document.createElement('input');      h.setAttribute('type','hidden');      h.setAttribute('name','id');      h.setAttribute('value',base_sample_ns+':'+sample_id);      doc.forms[i].appendChild(h);	     	    doc.forms[i].action=base_uri.substring(0,base_uri.indexOf("?"));   }	}}function onDeviceProfileSelectChange(aSampleId,aSelect){	changeDeviceProfile(aSampleId,aSelect.options[aSelect.selectedIndex].value,aSelect.options[aSelect.selectedIndex].getAttribute('devicewidth'));}function changeDeviceProfile(aSampleId,aProfileId,aWidth){  setCookie("dp",aProfileId);	iframe=document.getElementById(aSampleId+'iframe');	iframe.width=aWidth;	iframe.src=iframe.src.replace(/profile=.*&/,'profile='+aProfileId+'&');}function onLookAndFeelSelectChange(aSampleId,aSelect){	changeLookAndFeel(aSampleId,aSelect.options[aSelect.selectedIndex].id,unescape(aSelect.options[aSelect.selectedIndex].value));  setCookie("lf",aSelect.options[aSelect.selectedIndex].getAttribute('lfid'));}function changeLookAndFeel(aSampleId,aBaseURI,aLookAndFeelParam){	iframe=document.getElementById(aSampleId+'iframe');	iframe.src=iframe.src.replace(/url\=.*/,'url='+aBaseURI);	iframe.src=iframe.src.replace(/%3F.*/,'%3F'+escape(aLookAndFeelParam));}