/*Rednano js*/
function rednano_doClear(rednanoform)
{
     if (rednanoform.rednanotext.value == "Singapore" && rednanoform.rednanohiddenvalue.value == "initial")
 {
         rednanoform.rednanotext.value = "";
         rednanoform.rednanotext.style.color="black";
         rednanoform.rednanohiddenvalue.value = "end";
     }
     else if(rednanoform.rednanotext.value == ""){
      	rednanoform.rednanotext.value = "Singapore";
		rednanoform.rednanotext.className="input";
		rednanoform.rednanotext.style.color="";
        rednanoform.rednanohiddenvalue.value = "initial";
     }
 }
 function rednano_pop_up_search(rednanoform){
  queryString=rednanoform.rednanotext.value;
  if(!(queryString == "" || (queryString == "Singapore" && rednanoform.rednanohiddenvalue.value == "initial"))){
   	queryString=encodeURIComponent(queryString);
     finalUrl="http://www.rednano.sg/sfe/lwi.action?partnerid=singaporekopitiam&ss=y&view=lwi&querystring="+queryString;
   	var newWindow = window.open(finalUrl, "Rednano");

  }
  else if((queryString == "Singapore" && rednanoform.rednanohiddenvalue.value == "initial")||(queryString == "")){
 		finalUrl="http://www.rednano.sg?partnerid=singaporekopitiam&ss=y";
 	    var newWindow = window.open(finalUrl, "Rednano");
  }
  if(newWindow){
  		popup=true;
  }
  else{
  		alert("Please enable the Block Pop-Up Windows");
  }
  if(popup==true){
  			newWindow.focus();
  }

}
/*featured articles carousel*/
function swapthumb(){
	if(cur>4)cur = 0;
	jQuery('#cont'+(cur-1)).fadeOut('slow');
	jQuery('#photo_sec').html(jQuery('#photo'+cur).html());
	if(cur != 0){
		jQuery('#pid0').removeClass('photo active');
		jQuery('#pid0').addClass('photo');
	}
	if(cur != 1){
		jQuery('#pid1').removeClass('photo active');
		jQuery('#pid1').addClass('photo');
	}
	if(cur != 2){
		jQuery('#pid2').removeClass('photo active');
		jQuery('#pid2').addClass('photo');
	}
	if(cur != 3){
		jQuery('#pid3').removeClass('photo active');
		jQuery('#pid3').addClass('photo');
	}
	if(cur != 4){
		jQuery('#pid4').removeClass('photo active');
		jQuery('#pid4').addClass('photo');
	}
	jQuery('#pid'+cur).addClass('photo active');
	cur = cur+1;
}
/*blogger carousel*/
function switchblog(id){
	jQuery('#blog_sec').html(jQuery('#blog'+id).html());
	jQuery('#img71').removeClass('active');
	jQuery('#img72').removeClass('active');
	jQuery('#img73').removeClass('active');
	jQuery('#img74').removeClass('active');
	jQuery('#img75').removeClass('active');
	jQuery('#img'+id).addClass('active');					
}

/*Video player codes*/
function onYouTubePlayerReady(playerId) {
	ytplayer = document.getElementById("myytplayer");
    ytplayer.addEventListener("onError", "onPlayerError");
}
function onPlayerError(errorCode) {
   alert("An error occured: " + errorCode);
}
// functions for the api calls
function loadNewVideo(id, startSeconds) {
   if (ytplayer) {
      ytplayer.loadVideoById(id, parseInt(startSeconds));
	}
}

function changeDetails(vidid){
	document.getElementById('playing_details').innerHTML = document.getElementById(vidid).innerHTML;
}
function cueNewVideo(id, startSeconds) {
	if (ytplayer) {
    	ytplayer.cueVideoById(id, startSeconds);
    }
}