
function convert2JSON(s){
	var ob = eval('('+s+')');
	return ob;
}

function checkJSON(ob){
 return ob.IsError;
}

/* 
	Item-Detail listlerde Detail Divlerinden sadece birini show(), digerlerini hide eder.
	Initialize Etmek icin 
		initHoverItemDetail(ItemListContainerDivId, DetailListContainerDivId);
*/

function showHoverItemDetail(dest, seq){ 
	if(seq==null) return;
  n=$(dest).immediateDescendants().size();
  el=$(dest).immediateDescendants();
  el.each(function(e){ e.hide();})
  el[seq].show();
}

function initHoverItemDetail(list, detail){
  n=$(list).immediateDescendants().size();
  eli=$(list).immediateDescendants();
  eld=$(detail).immediateDescendants();
  for(var i=0; i<n; i++) {
		eli[i].descendants().each(
			function(el){
				el.setAttribute('seq', i); 
				el.observe('mouseover', 
					function(event){
						showHoverItemDetail(detail, Event.element(event).readAttribute('seq')); 
					}
				);
			}
		);
	};
	showHoverItemDetail(detail, 0);
}



////////////////////////////////////////
// JavaScript function to validate US
// phone number:
//
// (c) 2003
// No restrictions have been placed on the use
// of this code
//
// Updated Friday Jan 9 2004 to optionally ignore
// the area code:
//
// Input: a single string parameter and an
// optional boolean variable (default=true)
// Output: boolean true(1) or false(0)
//
// The function will return true for any
// alphanumeric string with the following
// sequence of characters:
// any number of spaces [optional], a single
// open parentheses [optional], any number of
// spaces [optional], 3 digits (area
// code), any number of spaces [optional], a
// single close parentheses [optional], a single
// dash [optional], any number of spaces
// [optional], 3 digits, any number of spaces
// [optional], a single dash [optional], any
// number of spaces [optional], 4 digits, any
// number of spaces [optional].
//
////////////////////////////////////////
function check_usphone(phonenumber,useareacode)
{
if(!useareacode)useareacode=1;
if((phonenumber.match(/^[ ]*[(]{0,1}[ ]*[0-9]{3,3}[ ]*[)]{0,1}[-]{0,1}[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null) && ((useareacode!=1) && (phonenumber.match(/^[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null))) return false;
return true;
} 


//cookie functions

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());
}


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 "";
}





//Base64 Encoding Decoding




// This code was written by Tyler Akins and has been placed in the
// public domain.  It would be nice if you left this header intact.
// Base64 code from Tyler Akins -- http://rumkin.com



function encode64(input) {
	
	var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}

function decode64(input) {
	
		var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}

function show_alert()
{
	if (!document.getElementById('CBox').checked) {
 	 	alert("Please accept the release agreement!");
 	 }
}















