var selectedimg=1;
var ug_id="";
var color_seleted='BG';
var theme=1;
var sound='off';
var width='280';
var height='390';
var bkground='GR';
function cameo(){
	var ok = document.getElementById("ok");
	if(ok!=null){
		ok.onclick = function() { Cameoformsubmit(); return false;}
	}
		
}
function CameoView(){
	
		
	if(document.frmwidgetSize){
		ShowCameoEmbedCode(selectedimg,theme,sound,width,height,bkground);
		var radiolist =  document.frmwidgetSize.imgsa;
		if(radiolist!=null){
			for(i=0;i<radiolist.length;i++){
				//alert(radiolist[i].name+i);
				if(whichBrowser()=='Internet Explorer'){
					radiolist[i].onclick=function() { changeImgSize(); }
				}else{
					radiolist[i].onchange=function() { changeImgSize(); return false;}
				}
			}
		}
		var color_list = document.frmwidgetSize.colorList;
		//alert(color_list);

		if(color_list!=null){
			//alert(color_list);
			for(i=0;i<color_list.length;i++){
				if(whichBrowser()=='Internet Explorer'){
					color_list[i].onclick=function() { changeImgSize(); }
				}else{
					color_list[i].onchange=function() { changeImgSize(); return false;}
				}
			}
		}
		var cameoSound = document.frmwidgetSize.soundoption;
		if(cameoSound!=null){
			for(i=0;i<cameoSound.length;i++){
				if(whichBrowser()=='Internet Explorer'){
					cameoSound[i].onclick=function() { setSoundOption(); }
				}else{
					cameoSound[i].onchange=function() { setSoundOption(); return false;}
				}
			}
		}
		
	}
}
function changeImgSize(jsclor){
	//alert("test color");
		if(jsclor==null){
			jsclor = color_seleted;
		}
		if(document.getElementById("280")!=null && document.getElementById("280").checked){
			selectedimg = document.getElementById("280").value;
			document.getElementById("see_how_long").className='hide';
			document.getElementById("see_how").className='show_text';
			width=280;
			height=390;
			
		}else if(document.getElementById("300")!=null && document.getElementById("300").checked){
			selectedimg = document.getElementById("300").value;
			//showhideImg(jsclor,'2');
			//document.getElementById("ban_img").height=250;
			//document.getElementById("ban_img").width=300;	
			document.getElementById("see_how_long").className='hide';
			document.getElementById("see_how").className='show_text';
			width=300;
			height=250;

	
		}else if(document.getElementById("728")!=null && document.getElementById("728").checked){		
			selectedimg = document.getElementById("728").value;
			document.getElementById("see_how_long").className='show_text';
			document.getElementById("see_how").className='hide';
			//showhideImg(jsclor,'3');
			//document.getElementById("ban_img").height=90;
			//document.getElementById("ban_img").width=728;
			width=728;
			height=90;

		}
		
		var color = getSelectedColorImg();
		
		showhideImg(color,selectedimg);
}

function getSelectedColorImg(){
	if(document.getElementById("BG")!=null && document.getElementById("BG").checked){
		color_seleted =  'BG';
		
	}else if(document.getElementById("G1")!=null && document.getElementById("G1").checked){
		color_seleted =  'G1';
		
	}else if(document.getElementById("WB")!=null && document.getElementById("WB").checked){
		color_seleted =  'WB';
		
	}
	//alert("doc"+document.getElementById("G1").checked);
//alert("doc"+document.getElementById("WB").checked);

	//alert("CS"+color_seleted);
	return color_seleted;
}

function changeColor(jsclor,jsht,jswidth){
	
	if(jsclor=='BG'){
		showhideImg(jsclor,'1');
	}else if(jsclor=='G1'){
		showhideImg(jsclor,'2');
				
	}else if(jsclor=='WB'){
		showhideImg(jsclor,'3'); 
				
	}
	
}

function Cameoformsubmit(){
	document.getElementById("frmcameo").submit();
}

function showhideImg(jscolor,type){
	
	color_seleted=jscolor;
	var jdId=jscolor+type;
	//alert("jdid"+jdId);
	var imglist=document.frmwidgetSize.cameo_img;
	
	var testimg = document.images;
	
	for(i=0;i<document.images.length;i++){
		
		if(document.images[i].name=="cameo_img"){
			//alert("cameo-img");
			if(document.images[i].id==jdId){
				//alert("cameo-img"+jdId);
				document.images[i].className='show';
			}else{
				//alert("2:"+document.images[i].name);
				document.images[i].className='hide';
			}
		}
	}
	//init();
	ShowCameoEmbedCode(type,getSelectedColor(),sound,width,height,bkground);
	
}

function Cameodisplay(){
	
	
			//alert("test cameo");
		//document.getElementById("imgs_view").className='show';
		//document.getElementById("widget_item").className='hide';
		//document.getElementById("swfDiv").className='photo hide';
		//document.getElementById("cameo_cd").className="textarea_widget show";
		//document.getElementById("holdtext").className="hide";
		ShowCameoEmbedCode(selectedimg,theme,sound,width,height,bkground);
	
	
}

function setSoundOption(){
	if(document.getElementById("on")!=null && document.getElementById("on").checked){
		sound ='on'
	}else{
		sound ='off'
	}
	ShowCameoEmbedCode(selectedimg,theme,sound,width,height,bkground);
}

function getSelectedImg(){
	return selectedimg;
}

function showWidget(){
	
	if(document.getElementById("wigdet_view").checked){
		
		document.getElementById("swfDiv").className='photo show';
		initWidget();
		showWidgetEmbedCode();
		//init();
		document.getElementById("widget_item").className='show';
		document.getElementById("holdtext").className="textarea_widget show";
		document.getElementById("cameo_cd").className="hide";
		if(document.getElementById("imgs_view")!=null){
			document.getElementById("imgs_view").className='hide';
		}
		
		
	}else{
		if(document.getElementById("widget_item")!=null){
			document.getElementById("widget_item").className='hide';
		}
		document.getElementById("cameo_cd").className="hide";
	}
	
}

function getSelectedColor(){
	
	if(color_seleted=="BG"){
		theme=1;
		bkground='GR';
	}
	else if(color_seleted=="G1"){
		theme=2;
		bkground='OR';
	}else if(color_seleted=="WB"){
		theme=3;
		bkground='BL';
	}
	return theme;
}

function getSoundOption(){
	return sound;
}

function widgetReset(){
	document.getElementById("width").value=150;
	document.getElementById("height").value=240;
	updateHeight();
}







	

