function getUrlShort(url){
var _url = window.location.href;
_url = _url.replace(/^.*(-p-\d+\.html).*$/ig, url+"/$1");
return _url;
}

function copyToClipboard(txt) {   
      if(window.clipboardData) {   
              window.clipboardData.clearData();   
              window.clipboardData.setData("Text", txt);  
			  alert("Sucefully copyed the short url to clipboard ! You can paste it on the blog,bbs,and any where else !") 
      } else if(navigator.userAgent.indexOf("Opera") != -1) {   
           window.location = txt;   
      } else if (window.netscape) {   
           try {   
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
           } catch (e) {   
                alert("Rejected by the browser! \n in the browser address bar enter 'about:config'\n then set 'signed.applets.codebase_principal_support'  as 'true'!");   
           }   
           var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);   
           if (!clip)   
                return;   
           var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);   
           if (!trans)   
                return;   
           trans.addDataFlavor('text/unicode');   
           var str = new Object();   
           var len = new Object();   
           var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);   
           var copytext = txt;   
           str.data = copytext;   
           trans.setTransferData("text/unicode",str,copytext.length*2);   
           var clipid = Components.interfaces.nsIClipboard;   
           if (!clip)   
                return false;   
           clip.setData(trans,null,clipid.kGlobalClipboard);   
           alert("Sucefully copyed the short url to clipboard ! You can paste it on the blog,bbs,and any where else !");
      }  
	  else{
		   alert("Your browser does not support the clipboard, copy your own hand, when you copy the URL after you paste to the BLOG, BBS or any other place, thank you!");
	  }
 }  



var errormsg="";
var isfocus=0;
function exist(id){
 var s=document.getElementById(id);
 if(s) {
  return true;
 }
 else{
  return false;
 }
}

function isdisable(id){
return $(id).disabled;
}


function Product_info_test_property(){

if (exist('attrib-1')){
if(!isdisable('attrib-1')){
if(($('attrib-1').selectedIndex)*1==0){
errormsg=errormsg+"Please Select Your Size! \n";
if(isfocus*1==0){
$('attrib-1').focus();
isfocus=1;
}
}
}
}

if (exist('attrib-2')){
if(!isdisable('attrib-2')){
if(($('attrib-2').selectedIndex)*1==0){
errormsg=errormsg+"Please Select Your Child Size! \n";
if(isfocus*1==0){
$('attrib-2').focus();
isfocus=1;
}
}
}
}


if (exist('attrib-3')){
if(!isdisable('attrib-3')){
if(($('attrib-3').selectedIndex)*1==0){
errormsg=errormsg+"Please Select Your Junior Size! \n";
if(isfocus*1==0){
$('attrib-3').focus();
isfocus=1;
}
}
}
}


if (exist('attrib-10')){
if(!isdisable('attrib-10')){
if(($('attrib-10').selectedIndex)*1==0){
errormsg=errormsg+"Please Select Your Color! \n";
if(isfocus*1==0){
$('attrib-10').focus();
isfocus=1;
}
}
}
}


if (exist('attrib-11')){
if(!isdisable('attrib-11')){
if(($('attrib-11').selectedIndex)*1==0){
errormsg=errormsg+"Please Select Your color! \n";
if(isfocus*1==0){
$('attrib-11').focus();
isfocus=1;
}
}
}
}


if (exist('check_attr')){
if ($('check_attr').checked){


if (exist('attrib-12-0')){
if(!isdisable('attrib-12-0')){
if(($('attrib-12-0').value)==""){
errormsg=errormsg+"Please Input Your Bust! \n";
if(isfocus*1==0){
$('attrib-12-0').focus();
isfocus=1;
}
}
}
}

if (exist('attrib-13-0')){
if(!isdisable('attrib-13-0')){
if(($('attrib-13-0').value)==""){
errormsg=errormsg+"Please Input Your Waist \n";
if(isfocus*1==0){
$('attrib-13-0').focus();
isfocus=1;
}
}
}
}

if (exist('attrib-14-0')){
if(!isdisable('attrib-14-0')){
if(($('attrib-14-0').value)==""){
errormsg=errormsg+"Please Input Your Hips \n";
if(isfocus*1==0){
$('attrib-14-0').focus();
isfocus=1;
}
}
}
}

if (exist('attrib-15-0')){
if(!isdisable('attrib-15-0')){
if(($('attrib-15-0').value)==""){
errormsg=errormsg+"Please Input Your Hollow to Hem \n";
if(isfocus*1==0){
$('attrib-15-0').focus();
isfocus=1;
}
}
}
}


if (exist('attrib-16-0')){
if(!isdisable('attrib-16-0')){
if(($('attrib-16-0').value)==""){
errormsg=errormsg+"Please Input Your Height \n";
if(isfocus*1==0){
$('attrib-16-0').focus();
isfocus=1;
}
}
}
}
}
}

<!--normal end-->



/*if (exist('attrib-7-0')){

if (exist('attrib-4-0')){
if(!isdisable('attrib-4-0')){
if(($('attrib-4-0').value)==""){
errormsg=errormsg+"Please Input Your Bust \n";
if(isfocus*1==0){
$('attrib-4-0').focus();
isfocus=1;
}
}
}
}

if (exist('attrib-5-0')){
if(!isdisable('attrib-5-0')){
if(($('attrib-5-0').value)==""){
errormsg=errormsg+"Please Input Your Upper Bust \n";
if(isfocus*1==0){
$('attrib-5-0').focus();
isfocus=1;
}
}
}
}

if (exist('attrib-6-0')){
if(!isdisable('attrib-6-0')){
if(($('attrib-6-0').value)==""){
errormsg=errormsg+"Please Input Your Around Bust \n";
if(isfocus*1==0){
$('attrib-6-0').focus();
isfocus=1;
}
}
}
}

if (exist('attrib-7-0')){
if(!isdisable('attrib-7-0')){
if(($('attrib-7-0').value)==""){
errormsg=errormsg+"Please Input Your Around Belly \n";
if(isfocus*1==0){
$('attrib-7-0').focus();
isfocus=1;
}
}
}
}

if (exist('attrib-8-0')){
if(!isdisable('attrib-8-0')){
if(($('attrib-8-0').value)==""){
errormsg=errormsg+"Please Input Your Hips \n";
if(isfocus*1==0){
$('attrib-8-0').focus();
isfocus=1;
}
}
}
}

if (exist('attrib-9-0')){
if(!isdisable('attrib-9-0')){
if(($('attrib-9-0').value)==""){
errormsg=errormsg+"Please Input Your Hollow to Hem \n";
if(isfocus*1==0){
$('attrib-9-0').focus();
isfocus=1;
}
}
}
}
}
*/

	
if (errormsg==""){
$('cart_quantity').submit();
}
else{
alert(errormsg);
}

errormsg="";
isfocus=0;
}

/*
function getfaqurl(){
var faqurl="http://dressale.dev.ug88.com/Dressale-FAQ-pg-82.html";
var currenturl=window.location.href;
if (currenturl.toString().indexOf("html")>0){
faqurl="http://dressale.dev.ug88.com/Dressale-FAQ-pg-82.html";
}else{
faqurl="http://dressale.dev.ug88.com/index.php?main_page=page&id=82";
}
return faqurl;
}
*/

function check_attr_input(){
 if ($('check_attr').checked == true) 
    { 
	if($('attrib-1') != null && $('attrib-1') !='' ) {$('attrib-1').selectedIndex=0;$('attrib-1').disabled=true;}
	if($('attrib-2') != null && $('attrib-2') !='' ) {$('attrib-2').selectedIndex=0;$('attrib-2').disabled=true;}
	if($('attrib-3') != null && $('attrib-3') !='' ) {$('attrib-3').selectedIndex=0;$('attrib-3').disabled=true;}	
		changediv('text_attribute',1);
 	} else{
	if($('attrib-1') != null && $('attrib-1') !='' ) {$('attrib-1').disabled=false;}
	if($('attrib-2') != null && $('attrib-2') !='' ) {$('attrib-2').disabled=false;}
	if($('attrib-3') != null && $('attrib-3') !='' ) {$('attrib-3').disabled=false;}
	    changediv('text_attribute',0);
	}
	
}



price_search_errormsg="";
function cate_price_search_test(){
patrn1=/^\d*$/;
patrn2=/^[1-9][0-9]*$/;
if ($('pfrom').value!=""){
	if (!patrn1.test($('pfrom').value)){
		price_search_errormsg= price_search_errormsg + "pfrom not price! \n"
	}
}

if ($('pto').value!="") { 
	if (!patrn2.test($('pto').value)){
		price_search_errormsg = price_search_errormsg + "pto not price! \n"
	}
}

if(($('pfrom').value=="") && ($('pto').value=="")){
 price_search_errormsg+=" you must input at least one price"
}

if (($('pfrom').value!="") && ($('pto').value!="")){
	if(($('pfrom').value-$('pto').value)>0){
		price_search_errormsg+="pfrom above pto!";
	}
}

			
if (price_search_errormsg!=""){
	alert(price_search_errormsg);
	}else{
	document.search_price.submit();
	}
	price_search_errormsg="";
}


function LTrim(str)
{
     return str.replace(/(^\s*)/g, "");
}
function blanktobr(par,allno){
var re=/\s+?/;
for(i=0;i<allno;i++){
	$(par+i).innerHTML=LTrim($(par+i).innerHTML).replace(re,"<br>");
	}
}




function move(elementID,final_x,final_y){
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  var elem = document.getElementById(elementID);
  elem.style.left = final_x + "px";
  elem.style.top = final_y + "px";
}

function moveElement(elementID,final_x,final_y,interval) {
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  var elem = document.getElementById(elementID);
  if (elem.movement) {
    clearTimeout(elem.movement);
  }
  if (!elem.style.left) {
    elem.style.left = "0px";
  }
  if (!elem.style.top) {
    elem.style.top = "0px";
  }
  var xpos = parseInt(elem.style.left);
  var ypos = parseInt(elem.style.top);
  if (xpos == final_x  &&  ypos == final_y) {
  return true;
  }
  if (xpos < final_x) {
    var dist = Math.ceil((final_x - xpos)/40);
    xpos = xpos + dist;
  }
  if (xpos > final_x) {
    var dist = Math.ceil((xpos - final_x)/40);
    xpos = xpos - dist;
  }
  if (ypos < final_y) {
    var dist = Math.ceil((final_y - ypos)/60);
    ypos = ypos + dist;
  }
  if (ypos > final_y) {
    var dist = Math.ceil((ypos - final_y)/60);
    ypos = ypos - dist;
  }
  elem.style.left = xpos + "px";
  elem.style.top = ypos + "px";
  var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
  elem.movement = setTimeout(repeat,interval);
}



function setwidth(no,maximg){
$('imgbox'+no).style.width=maximg*131;
}

function moveimg1(tag){
if (tag==1){
	if (now1<=0){
		now1=maximg1-5;
		move('imgbox1',-(now1+1)*131,15);
		moveElement('imgbox1',-now1*131,15,2);
	}else{
		now1--;
		moveElement('imgbox1',-now1*131,15,2);
	}
}else{
	if(now1>=maximg1-5){
		now1=0;
		move('imgbox1',-(now1-1)*131,15);
		moveElement('imgbox1',-now1*131,15,2);
	}else{
		now1++;
		moveElement('imgbox1',-now1*131,15,2);
	}
}
}

function moveimg2(tag){
if (tag==1){
	if (now2<=0){
		now2=maximg2-5;
		move('imgbox2',-(now2+1)*131,15);
		moveElement('imgbox2',-now2*131,15,2);
	}else{
		now2--;
		moveElement('imgbox2',-now2*131,15,2);
	}
}else{
	if(now2>=maximg2-5){
		now2=0;
		move('imgbox2',-(now2-1)*131,15);
		moveElement('imgbox2',-now2*131,15,2);
	}else{
		now2++;
		moveElement('imgbox2',-now2*131,15,2);
	}
}
}

function moveimg3(tag){
if (tag==1){
	if (now3<=0){
		now3=maximg3-5;
		move('imgbox3',-(now3+1)*131,15);
		moveElement('imgbox3',-now3*131,15,2);
	}else{
		now3--;
		moveElement('imgbox3',-now3*131,15,2);
	}
}else{
	if(now3>=maximg3-5){
		now3=0;
		move('imgbox3',-(now3-1)*131,15);
		moveElement('imgbox3',-now3*131,15,2);
	}else{
		now3++;
		moveElement('imgbox3',-now3*131,15,2);
	}
}
}

